home *** CD-ROM | disk | FTP | other *** search
- /* viewfinf.c file - moves to new positions in the file */
- #include "stdio.h"
- #include "cminor.h"
- #include "viewparm.h"
- long top_of_page ; /* position in file of top of display page */
- long where_now() ; /* returns current file position */
-
- int move_forward(nlines) /* move forward n lines */
- int nlines ; /* number of lines to move */
- {
- int c ; /* hold chars read here */
-
- move_to(top_of_page) ; /* start at top of page */
- while( nlines > 0 )
- { c = get_next_char() ;
- if( c == END_LINE ) /* check for end of line */
- nlines = nlines - 1 ;
- if( c == EOF_MARK ) /* check for end of file */
- { set_top_page(); /* yes - mark as top of page */
- return ; /* and exit */
- }
- }
- set_top_page() ; /* mark this top of page */
- }
-
- int move_backward(nlines) /* move backward n lines */
- int nlines ; /* number of lines to move */
- { /* (zero = start of this line) */
- int c ; /* hold char here */
-
- move_to(top_of_page) ; /* start at top of page */
- nlines = nlines + 1 ; /* add one for current line */
- while( nlines > 0 )
- { c = get_previous_char() ;
- if( c == END_LINE )
- nlines = nlines - 1;
- if( c == BOF_MARK ) /* check for BOF */
- { set_top_page() ; /* yes - mark as top of page */
- return ;
- }
- } /* we're before an end_line */
- get_next_char() ; /* move past it */
- set_top_page() ; /* mark as top of page */
- }
-
- int set_top_page()
- {
- top_of_page = where_now() ;
- }